package com.ms.mishitong.controller;



import com.ms.mishitong.dto.Result;
import com.ms.mishitong.service.IFollowService;
import com.ms.mishitong.utils.ThroadLocal;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/follow")
public class FollowController {
     @Resource
     private IFollowService followService;
    @PutMapping("/{id}/{isFollow}")
    public Result follow(@PathVariable Long id, @PathVariable Boolean isFollow){
        return followService.follow(id,isFollow);

    }
    @GetMapping("/or/not/{id}")
    public Result follow(@PathVariable Long id){
        return followService.isFollow(id);
    }
    @GetMapping("/common/{id}")
    public Result followcommon(@PathVariable("id") Long id){
         return followService.followcommon(id);
    }
    @GetMapping("/mutual")
    public Result mutual(@RequestParam(required = false) Long cursor,@RequestParam(required = false) Integer pageSize){
        if (pageSize == null || pageSize <= 0) {
            pageSize = 10;  // 默认每页10条
        }
        if(cursor == null){
            cursor = 0L;
        }
         return followService.getMutual(cursor,pageSize);
    }
    @GetMapping("/fans")
    public Result getFollows(){
        Long id = ThroadLocal.get().getId();
        log.info("获取粉丝列表：{}", followService.getFollows(id));
        return Result.ok(followService.getFollows(id));
    }




}
